{% extends 'base.html' %}

{% block title %}提交规则 - {{ site_info.site_name }}{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-10">
        <div class="card">
            <div class="card-header bg-primary text-white">
                <h2 class="mb-0">提交新规则</h2>
            </div>
            <div class="card-body">
                <p class="lead mb-4">
                    欢迎提交您的Cursor规则！请填写以下表单，我们会对您的提交进行审核。
                </p>
                
                <form method="post">
                    {% csrf_token %}
                    
                    <!-- 标题 -->
                    <div class="mb-3">
                        <label for="{{ form.title.id_for_label }}" class="form-label">{{ form.title.label }}</label>
                        {{ form.title }}
                        {% if form.title.help_text %}
                            <div class="form-text">{{ form.title.help_text }}</div>
                        {% endif %}
                        {% if form.title.errors %}
                            <div class="invalid-feedback d-block">
                                {% for error in form.title.errors %}
                                    {{ error }}
                                {% endfor %}
                            </div>
                        {% endif %}
                    </div>
                    
                    <!-- 内容 -->
                    <div class="mb-3">
                        <label for="{{ form.content.id_for_label }}" class="form-label">{{ form.content.label }}</label>
                        {{ form.content }}
                        {% if form.content.help_text %}
                            <div class="form-text">{{ form.content.help_text }}</div>
                        {% endif %}
                        {% if form.content.errors %}
                            <div class="invalid-feedback d-block">
                                {% for error in form.content.errors %}
                                    {{ error }}
                                {% endfor %}
                            </div>
                        {% endif %}
                    </div>
                    
                    <!-- 标签 -->
                    <div class="mb-3">
                        <label class="form-label">{{ form.tags.label }}</label>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="card mb-3">
                                    <div class="card-header bg-primary text-white">编程语言</div>
                                    <div class="card-body">
                                        {% for group, options in form.fields.tags.widget.choices %}
                                            {% if group == '编程语言' %}
                                                {% for value, label in options %}
                                                    <div class="form-check">
                                                        <input type="checkbox" name="{{ form.tags.name }}" value="{{ value }}" id="id_tags_{{ value }}" class="form-check-input">
                                                        <label for="id_tags_{{ value }}" class="form-check-label">{{ label }}</label>
                                                    </div>
                                                {% endfor %}
                                            {% endif %}
                                        {% endfor %}
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="card">
                                    <div class="card-header bg-success text-white">使用场景</div>
                                    <div class="card-body">
                                        {% for group, options in form.fields.tags.widget.choices %}
                                            {% if group == '使用场景' %}
                                                {% for value, label in options %}
                                                    <div class="form-check">
                                                        <input type="checkbox" name="{{ form.tags.name }}" value="{{ value }}" id="id_tags_{{ value }}" class="form-check-input">
                                                        <label for="id_tags_{{ value }}" class="form-check-label">{{ label }}</label>
                                                    </div>
                                                {% endfor %}
                                            {% endif %}
                                        {% endfor %}
                                    </div>
                                </div>
                            </div>
                        </div>
                        {% if form.tags.help_text %}
                            <div class="form-text">{{ form.tags.help_text }}</div>
                        {% endif %}
                        {% if form.tags.errors %}
                            <div class="invalid-feedback d-block">
                                {% for error in form.tags.errors %}
                                    {{ error }}
                                {% endfor %}
                            </div>
                        {% endif %}
                    </div>
                    
                    <div class="alert alert-info">
                        <i class="fas fa-info-circle me-2"></i> 您的规则提交后将由管理员审核，审核通过后才会在网站上显示。
                    </div>
                    
                    <div class="d-flex justify-content-between">
                        <a href="{% url 'rules:list' %}" class="btn btn-outline-secondary">取消</a>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-paper-plane me-1"></i> 提交规则
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %} 